package com.huawei.appmarket.oobe.app;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build.VERSION;
import androidx.annotation.RequiresApi;
import com.huawei.secure.android.common.intent.SafeBroadcastReceiver;
import o.dli;
import o.Logger;
import o.ContentManager;

public class OOBESimStateReceiver extends SafeBroadcastReceiver {
    public void onReceiveMsg(Context context, Intent intent) {
        if ("android.intent.action.SIM_STATE_CHANGED".equals(intent.getAction()) && VERSION.SDK_INT >= 26 && !dli.ˏ(context) && intent.getExtras() != null) {
            String str = null;
            try {
                str = intent.getExtras().getString("ss");
            } catch (Exception e) {
                Logger.ˋ("OOBE", "OOBESimStateReceiver:getString exception");
            }
            if (str != null) {
                ˎ(context, str);
            }
        }
    }

    private void ˎ(Context context, String str) {
        if (str.equals("READY")) {
            boolean z;
            Logger.ˎ("OOBE", "OOBESimStateReceiver:state ready");
            if (dli.ˋ()) {
                z = true;
            } else {
                z = dli.ˏॱ(context);
            }
            if (dli.ˊ(context).getBoolean("notificationBlockedBySim", false)) {
                if (!dli.ˊॱ(context) && z) {
                    OOBEQueryIfSupportJobService.schedule(context, 1);
                }
                dli.ˊ(context).edit().putBoolean("notificationBlockedBySim", false).commit();
                return;
            }
            ˏ(context, z);
        } else if (str.equals("ABSENT")) {
            Logger.ˎ("OOBE", "OOBESimStateReceiver:state ABSENT");
            if (!dli.ᐝ(context)) {
                dli.ͺ(context);
            }
        } else {
            Logger.ˋ("OOBE", "OOBESimStateReceiver:state UNKNOWN");
        }
    }

    @RequiresApi(api = 24)
    private void ˏ(Context context, boolean z) {
        String string = dli.ˊ(context).getString("lastVNKey", "");
        String ˏ = dli.ˏ();
        if (!dli.ˊ(context).getBoolean("simChangeNotify", false) || !z || ˏ.equals(string)) {
            Logger.ˎ("OOBE", "simcard ready, but skipped");
        } else if (dli.ˊॱ(context)) {
            Logger.ˎ("OOBE", "simcard ready, but skipped as notifciation showing");
        } else {
            OOBEQueryIfSupportJobService.schedule(context, 2, false);
        }
    }

    public static void disable() {
        Context ˋ = ContentManager.getInstant().getContext();
        ˋ.getPackageManager().setComponentEnabledSetting(new ComponentName(ˋ, OOBESimStateReceiver.class), 2, 1);
    }
}
